// Rank List Related Api
import request from 'Utils/request'

/**
 * Get rank list of new song.
 * http://m.kugou.com/?json=true
 */
export function getNewSongRankList () {
    return new Promise((resolve, reject) => {
        request
            .get('/mApi/?json=true')
            .then(data => {
                resolve(data)
            })
            .catch(err => {
                reject(err)
            })
    })
}

/**
 * Get rank list classify.
 * http://m.kugou.com/rank/list&json=true
 */
export function getRankListClassify () {
    return new Promise((resolve, reject) => {
        request
            .get('/mApi/rank/list&json=true')
            .then(data => {
                resolve(data)
            })
            .catch(err => {
                reject(err)
            })
    })
}

/**
 * Get details of rank list.
 * http://m.kugou.com/rank/info/?rankid=8888&page=1&json=true
 * @param {String} rankid The sign of classify of rank list.
 */
export function getRankListDetails (rankid) {
    return new Promise((resolve, reject) => {
        request
            .get(`/mApi/rank/info/?rankid=${rankid}&page=1&json=true`)
            .then(data => {
                resolve(data)
            })
            .catch(err => {
                reject(err)
            })
    })
}
